﻿using System;
using System.Collections;
using System.Linq.Expressions;
using System.Reflection;

namespace MemoDb
{
    public interface ITypeConfigurator
    {
        ITypeConfigurator SetId<TId>(PropertyInfo id, Func<TId, TId> getNewId, TId unsavedValue = default(TId));
        ITypeConfigurator SetId<TId>(string id, Func<TId, TId> getNewId, TId unsavedValue = default(TId));
        ITypeConfigurator SetId(PropertyInfo id, bool autoAssign = false, object unsavedValue = null);
        ITypeConfigurator SetId(string id, bool autoAssign = false, object unsavedValue = null);
        ITypeConfigurator CasacadeInsert(string reference, bool cascade = true);
        ITypeConfigurator CasacadeInsert(PropertyInfo reference, bool cascade = true);
        ITypeConfigurator CasacadeDeleteOrphans(string collection, bool cascade = true);
        ITypeConfigurator CasacadeDeleteOrphans(PropertyInfo collection, bool cascade = true);
    }

    public interface ITypeConfigurator<T>
    {
        ITypeConfigurator<T> SetId<TId>(PropertyInfo id, Func<TId, TId> getNewId, TId unsavedValue = default(TId));
        ITypeConfigurator<T> SetId<TId>(string id, Func<TId, TId> getNewId, TId unsavedValue = default(TId));
        ITypeConfigurator<T> SetId(PropertyInfo id, bool autoAssign = false, object unsavedValue = null);
        ITypeConfigurator<T> SetId<TId>(Expression<Func<T, TId>> id, Func<TId, TId> getNewId, TId unsavedValue = default(TId));
        ITypeConfigurator<T> SetId(string id, bool autoAssign = false, object unsavedValue = null);
        ITypeConfigurator<T> CasacadeInsert(string reference, bool cascade = true);
        ITypeConfigurator<T> CasacadeInsert(PropertyInfo reference, bool cascade = true);
        ITypeConfigurator<T> CasacadeInsert(Expression<Func<T, object>> reference, bool cascade=true);
        ITypeConfigurator<T> CasacadeDeleteOrphans(string collection, bool cascade = true);
        ITypeConfigurator<T> CasacadeDeleteOrphans(PropertyInfo collection, bool cascade = true);
        ITypeConfigurator<T> CasacadeDeleteOrphans(Expression<Func<T, IEnumerable>> collection, bool cascade = true);
    }
}